<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			console.log('one', new Date().getTime())
			var ss = [
				{
				  "unique": "4",
				  "menuTitle": "资源管理",
				  "children": [
				    {
				      "unique": "4-1",
				      "menuTitle": "系统设置",
				    },
				    {
				      "unique": "4-2",
				      "menuTitle": "下载管理",
				      "children": [
				        {
				          "unique": "4-2-1",
				          "menuTitle": "图片下载"
				        },
				        {
				          "unique": "4-2-2",
				          "menuTitle": "文件下载"
				        }
				      ]
				    }
				  ]
				}
			];
			var unique = "4-2-2";
			let result_ss = [];
			let kk = '';
			
			function transfromRoute(unique){
				var unique_arr = [];
				var a1 = unique.split('-')[0];
				var a2 = unique.substring(0,unique.length - unique.indexOf('-') -1);
				unique_arr.push(a1,a2,unique);
				console.log('最后输出', new Set(unique_arr));
				return new Set(unique_arr);
			}
			function ouputObject(ss) {
				for (let i in ss) {
					result_ss.push(ss[i]);
					if (ss[i].children) {
						ouputObject(ss[i].children)
					}
				}
			}
			function ouputName() {
				var a=[];
				var arr = Array.from(transfromRoute(unique));
				console.log('arr', arr, result_ss);
				// 资源管理 - 下载管理 - 文件下载
				for (var i = 0; i < result_ss.length; i++) {
					if(arr.indexOf(result_ss[i].unique) > -1) {
						kk += result_ss[i].menuTitle + '-'
					}
				}
				console.log('end',kk, new Date().getTime())
			}
			// 调用
			ouputObject(ss);
			ouputName();
		</script>
	</head>
	<body>
	</body>
</html>
